package com.wss.service.user.config;


import com.wss.common.exceptions.WssException;
import com.wss.common.model.Result;
import lombok.extern.slf4j.Slf4j;
import org.springframework.http.HttpStatus;
import org.springframework.web.bind.annotation.ExceptionHandler;
import org.springframework.web.bind.annotation.ResponseBody;
import org.springframework.web.bind.annotation.ResponseStatus;

/**
 * 全局异常处理类
 *
 * @author: Fred
 * @email 453086@qq.com
 * @create: 2021-07-16 11:07
 */
@ResponseBody
@Slf4j
public class ExceptionsHandler {

    /**
     * 业务异常
     *
     * @param ex
     * @return
     */
    @ExceptionHandler(WssException.class)
    @ResponseStatus(HttpStatus.INTERNAL_SERVER_ERROR)
    public Result ExceptionsHandler(WssException ex) {
        log.error(ex.getMessage(),ex);
        return Result.fail(ex.getMessage());
    }




}